import path from "path";
import { $context } from "@ap/extension";
import * as vscode from "vscode";
export default function chatjptLogView() {
  const web = vscode.window.createWebviewPanel(
    "arenaPro",
    "Chat吉PT对话日志",
    vscode.ViewColumn.Active,
    { enableScripts: true, retainContextWhenHidden: true },
  );
  web.webview.html = getWebviewContent();
  web.iconPath = vscode.Uri.file(
    path.join($context.extensionPath, "image", "icon.png"),
  );
}

function getWebviewContent() {
  return `
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
        body {
            padding: 0 0px!important;
        }
    </style>
</head>
<body>
<iframe id="box3iframe" name="box3iframe" height="100%" width="100%" src="https://box3lab.com/chatjptlog?all=1&vsc=1" scrolling="auto" frameborder="0"></iframe>
<script>
    var box3iframe = document.getElementById("box3iframe"); 
    function changeFrameHeightAndWidth() { 
        box3iframe.height = document.documentElement.clientHeight;
        box3iframe.width = document.documentElement.clientWidth;
    }
    changeFrameHeightAndWidth();
    window.onresize = function() {
        changeFrameHeightAndWidth(); 
    }
</script>
</body>
</html>`;
}
